<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        const obj = {
            isFunction(fn) {
                return typeof fn !== 'function'
            },
            calls(that, ...arg) {
                if (arguments.length === 0) { 
                    window.fn = this
                    window.fn()
                    Reflect.deleteProperty(window, "fn")
                    console.log(window.fn)
                    return
                }
                const fn = this
                const object = that || window
                //这里要注意可能对象身上已经有该属性 需要一个唯一的键名
                const keys = Symbol(`${Math.random() + Date.now()}`)
                object[keys] = fn
                object[keys](...arg)
                Reflect.deleteProperty(object, keys)
            },
            binds(object, ...arg) {
                const fn = this
                //这里要注意可能对象身上已经有该属性 需要一个唯一的键名
                let bind_args = arg
                return (...args) => {
                    fn.call(object, ...bind_args, ...args)
                    bind_args = null
                }
            },
            applys(object, arg) {
                const fn = this
                //这里要注意可能对象身上已经有该属性 需要一个唯一的键名
                fn.call(object, ...arg)
            }

        }
        Object.keys(obj).forEach((key) => {
            Object.prototype[key] = obj[key]
        })

        function change(name, age) {
            console.log(this)
            this.name = name
            this.age = age
        }

        const person = {}
        change.calls()
        // change.calls(person, 'zs', 24)
        // const now = change.binds(person, 'ls')
        // now(25)
        // change.applys(person, ['w5', 26])
        console.log(person)
    </script>
</head>
<body>

</body>
</html>
